package com.itheima.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.itheima.domain.Book;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Controller
public class AccountController {
    @RequestMapping("/showData3")
    @ResponseBody
    public String showData3() throws JsonProcessingException {
        Book book = new Book();
        book.setName("SpringMVC入门实战");
        book.setPrice(66.6d);
        ObjectMapper om = new ObjectMapper();
        return om.writeValueAsString(book);
    }

    @RequestMapping("/showData4")
    @ResponseBody
    public Book showData4(){
        Book book = new Book();
        book.setName("SpringMVC入门实战");
        book.setPrice(66.6d);
        return book;
    }
    @RequestMapping("/showData5")
    @ResponseBody
    public String showData5() {
        //return "{'name':'Jock', age : 10}";
        return "我是中文";
    }
}
